<?php
require_once APPPATH."models/model_dao.php";
class Model_option extends Model_dao {

    function __construct() {
        // Call the Model constructor
        parent::Model_dao("tbl_options");
    }

	/**
	 *
	 *
	 */
    function find_all(){
		$query = $this->db->get($this->_tbl_name);
        if ($query->num_rows() > 0) {
            return $query->result_array();
        }
        return null;
    }
	/**
	 *
	 * @param object $id
	 * @return
	 */
	function delete($id){
		if (intval($id)) {
            $this->db->where('id', $id);
			$this->db->delete($this->_tbl_name);
		}
	}

	/**
	 *
	 * @param object $id
	 * @return
	 */
    function find($id){
    	if (intval($id)) {
            $this->db->where('id', $id);
			$query = $this->db->get($this->_tbl_name);
	        if ($query->num_rows() > 0) {
	            return $query->first_row('array');
	        }
		}
	    return null;
    }

	/**
     *
     *
     * @param object $data
     * @return
     */
    function insert($data) {
        $data['createddate'] = date("Y-m-d h:i:s");
        $data['modifieddate'] = date("Y-m-d h:i:s");
        return parent::insert($data);
    }

    /**
     *
     * @param object $id
     * @param object $data
     * @return
     */
    function update($id, $data) {
        if (intval($id)) {
            $this->db->where('id', $id);
        	$data['modifieddate'] = date("Y-m-d h:i:s");
            return $this->db->update($this->_tbl_name, $data);
        }
    }
}
?>
